#coding:utf-8
import os
from common.koufuApi import KoufuApi

__author__ = 'yangxianming'

from common.KoufuConf import KoufuConf
import json
import requests


def case():
    #初始化必要的参数
    kou_fu_conf = KoufuConf()
    test_url = kou_fu_conf.koufu_prod_domain + "/api/koufu"
    kou_fu_api = KoufuApi()
    script_name = os.path.basename(__file__)

    #结果判断
    tf = True
    try:
        #获取首页信息
        p = kou_fu_api.get_efuli_koufu_index_data_data()
        r = requests.post(test_url, data=json.dumps(p), headers=kou_fu_conf.headers)
        print("这个是接口efuli.koufu.index.data返回的全部参数", r.content.decode("utf-8"))

        #企业管理的信息加载
        p = kou_fu_api.get_efuli_koufu_mealrule_query_combo_goods_data()
        r = requests.post(test_url, data=json.dumps(p), headers=kou_fu_conf.headers)
        print("这个是接口efuli_koufu_mealrule_query_combo_goods返回的全部参数", r.content.decode("utf-8"))

        #企业账单月账单
        p = kou_fu_api.get_efuli_corp_account_record_search_new_data()
        r = requests.post(test_url, data=json.dumps(p), headers=kou_fu_conf.headers)
        print("这个是接口efuli_corp_account_record_search_new返回的全部参数", r.content.decode("utf-8"))

        #口福当月对账单

        p = kou_fu_api.get_efuli_koufu_meal_bill_file_pdf_send_month_data()
        r = requests.post(test_url, data=json.dumps(p), headers=kou_fu_conf.headers)
        print("这个是接口efuli_koufu_meal_bill_file_pdf_send_month返回的全部参数", r.content.decode("utf-8"))

        #企业账单的日账单
        p = kou_fu_api.get_efuli_corp_account_record_day_search_data()
        r = requests.post(test_url, data=json.dumps(p), headers=kou_fu_conf.headers)
        print("这个是接口efuli.koufu.corp.account.record.day.search返回的全部参数", r.content.decode("utf-8"))

        #当月日账单明细excel导出
        p = kou_fu_api.get_efuli_meal_bill_file_send_day_data()
        r = requests.post(test_url, data=json.dumps(p), headers=kou_fu_conf.headers)
        print("这个是接口efuli.koufu.corp.account.record.day.search返回的全部参数", r.content.decode("utf-8"))

        test_result = r.json()
        desc = test_result["return_desc"]
        print("返回参数return_desc值", desc)

        #具体判断


    except Exception as e:
        err_info = str(e).replace("'", "").replace("\"", "")
        test_result = "非预期的异常,脚本文件:" + script_name + "; 错误信息：" + err_info
        tf = -2

    # 定义预期描述

    print(str(tf))

    expect_result = "预期结果:return_desc=success"

    # 返回测试结果 第一个参数:True or False    第二个参数测试结果描述

    return tf, [test_result, expect_result]


case()